package com.five.api;

import com.five.dto.CommentCreateDTO;
import com.five.dto.IdRequest;
import com.five.fallback.ReaderFallback;
import com.five.pojo.Comment;
import com.five.result.Result;
import com.five.vo.CommentTreeVO;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


@FeignClient(value = "comment-service", fallbackFactory = ReaderFallback.class)
@EnableFeignClients
public interface CommentServiceAPI {
    /**
     * 创建评论/回复
     *
     * @param token 登陆人token
     * @param dto   创建参数
     *              novelId: 书籍ID
     *              parentId: 父级评论ID
     *              content: 评论内容
     */
    @PostMapping("/comment/create")
    Result<Long> createComment(@RequestHeader("token") String token, CommentCreateDTO dto);

    /**
     * 查询书籍的所有评论
     *
     * @param idRequest 书籍ID
     */
    @PostMapping("/comment/tree")
    Result<List<CommentTreeVO>> getCommentTree(@RequestBody IdRequest idRequest);

    /**
     * 删除自己的评论/回复
     *
     * @param commentId 评论ID
     */
    @PostMapping("/comment/delete")
    Result<Void> deleteComment(@RequestHeader("token") String token, Long commentId);

    /**
     * 查询登陆人的所有评论
     * @param token 登陆人token
     */
    @PostMapping("/comment/listByLogininfo")
    Result<List<Comment>> listByLogininfo(@RequestHeader("token") String token);
}